﻿using HamcoWcs.Models.Common;
using HamcoWcs.Models.Common.Enums;
using HamcoWcs.Models.DeviceMsgs;
using HamcoWcs.Models.DeviceMsgs.SrmMsgs;
using HamcoWcs.Models.Devices;

namespace HamcoWcs.Models.DeviceMsgQueues
{
    public class DeviceMsgQueueDto : BaseModel
    {
        public DeviceMsgQueueDto() { }


        public DeviceMsgQueueDto(PconDto pcon, PconSendMsg msg)
          : this(pcon.PlcName, pcon.PconName.ToString(), pcon.SendStartPoint, msg.ToJson(), ((EnumPconSendMsg)msg.Request).ToString())
        { }

        public DeviceMsgQueueDto(PconDto pcon, PconRecvMsg msg)
        : this(pcon.PlcName, pcon.PconName.ToString(), pcon.SendStartPoint, msg.ToJson(), ((EnumPconRecvMsg)msg.Request).ToString())
        { }

        public DeviceMsgQueueDto(SrmDto srm, SrmRecvMsg msg)
          : this(srm.PlcName, srm.SrmName, srm.SendStartPoint, msg.ToJson(), ((EnumSrmRecvMsg)msg.Request).ToString())
        { }

        public DeviceMsgQueueDto(SrmDto srm, SrmSendMsg msg)
           : this(srm.PlcName, srm.SrmName, srm.SendStartPoint, msg.ToJson(), ((EnumSrmSendMsg)msg.Request).ToString())
        { }

        public DeviceMsgQueueDto(string plcName, string deviceName, int startPoint, string msgValue, string messageName, string taskId = "")
        {
            PlcName = plcName;
            DeviceName = deviceName;
            StartPoint = startPoint;
            MsgValue = msgValue;
        }

        public string PlcName { get; set; }
        public string DeviceName { get; set; }
        public int StartPoint { get; set; }
        public string MsgValue { get; set; }
        public string MessageName { get; set; }
        public string TaskId { get; set; }
    }
}